<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
.zi{
     width: 300px;
     height: 300px;
     border: 5px solid black;
}
.cd{
    width: 500px;
    height:500px;
    background-color: rgb(232, 186, 186);
    float: right;
    opacity: 0;
}
.hong{
    width: 100px;
    height: 100px;
    background-color: red;
}
.huang{
    width: 100px;
    height: 100px;
    background-color: yellow;
}
.lan{
    width: 100px;
    height: 100px;
    background-color: blue;
}
.k200{
    width: 100px;
    height: 100px;

}
.k300{
    width: 100px;
    height: 100px;

}
.k400{
    width: 100px;
    height: 100px;
 
}
.g200{
    width: 100px;
    height: 100px;

}
.g300{
    width: 100px;
    height: 100px;

}
.g400{
    width: 100px;
    height: 100px;
 
}
    </style>
</head>
<body>
    <div>

        <p><font style="font-size: 20px;">请为下面的div设置样式</font> <button class="sz">点击设置</button> <button class="re">点击设置为红色</button></p>


        <div class="zi">
        </div>


        <div class="cd">
            <p>选择背景颜色: <button class="hong">红</button>  <button class="huang">黄</button>  <button class="lan">蓝</button></p>
            <p>选择背景宽度: <button class="k200">200</button>  <button class="k300">300</button>  <button class="k400">400</button></p>
            <p>选择背景高度: <button class="g200">200</button>  <button class="g300">300</button>  <button class="g400">400</button></p>
     
        </div>
    </div>
    
</body>
</html>
<script>
    var sz=document.querySelector(".sz");
    var cd=document.querySelector(".cd");
    var zi=document.querySelector(".zi")
    sz.onclick=function(){
       cd.style. opacity=1;
    }
    var re=document.querySelector(".re");

    re.onclick=function(){
        zi.style.backgroundColor="red"
    }
</script>